#ifndef SCRIPTEDITOR_H
#define SCRIPTEDITOR_H

#include <QTextEdit>
#include <QtGui>
#include "highlighter.h"

class ScriptEditor : public QTextEdit
{
    Q_OBJECT

    QCompleter *m_completer;
    QString m_currentFile;
    bool m_dirty;
    Highlighter *m_highlighter;
    QCompleter *c;

    void setDirty(bool value);
    QString textUnderCursor() const;

public:
    explicit ScriptEditor(QWidget *parent = 0);

    bool isDirty(){ return m_dirty; }
    const QString &getCurrentFile(){ return m_currentFile;}
    void setCurrentFile(const QString &file){ m_currentFile = file; }

    void setCompleter(QCompleter *c);
    QCompleter *completer() const;

protected:
     void keyPressEvent(QKeyEvent *e);
     void focusInEvent(QFocusEvent *e);

signals:
    void dirtyChanged(bool value);

private slots:
     void insertCompletion(const QString &completion);

public slots:
    void loadScript(const QString &fileName);
    bool saveScript();
    void setDirty();

};

#endif // SCRIPTEDITOR_H
